home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / cntrlc / trick.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  2.9 KB  |  87 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   3060
  5.    ClientLeft      =   690
  6.    ClientTop       =   1485
  7.    ClientWidth     =   6510
  8.    Height          =   3465
  9.    Left            =   630
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3060
  12.    ScaleWidth      =   6510
  13.    Top             =   1140
  14.    Width           =   6630
  15.    Begin ComboBox Combo1 
  16.       Height          =   300
  17.       Left            =   120
  18.       TabIndex        =   3
  19.       Text            =   "FRAME"
  20.       Top             =   600
  21.       Width           =   1455
  22.    End
  23.    Begin Frame Frame1 
  24.       Caption         =   "0"
  25.       Height          =   1695
  26.       Index           =   0
  27.       Left            =   1800
  28.       TabIndex        =   0
  29.       Top             =   480
  30.       Width           =   3135
  31.       Begin CheckBox Check1 
  32.          Caption         =   "Check1"
  33.          Height          =   375
  34.          Index           =   0
  35.          Left            =   120
  36.          TabIndex        =   1
  37.          Top             =   600
  38.          Width           =   2655
  39.       End
  40.    End
  41.    Begin Label Label2 
  42.       Caption         =   "Select Frame"
  43.       Height          =   255
  44.       Left            =   120
  45.       TabIndex        =   4
  46.       Top             =   240
  47.       Width           =   1215
  48.    End
  49.    Begin Label Label1 
  50.       Caption         =   "CLICK ON FORM TO CREATE NEW FRAME"
  51.       Height          =   855
  52.       Left            =   120
  53.       TabIndex        =   2
  54.       Top             =   2160
  55.       Width           =   1335
  56.    End
  57. Option Explicit
  58. Declare Function SetParent Lib "User" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
  59. Sub Check1_Click (index As Integer)
  60.           
  61. End Sub
  62. Sub Combo1_click ()
  63.     frame1(combo1.ListIndex).ZOrder 0
  64. End Sub
  65. Sub Form_click ()
  66.     Static inext As Integer         ' Declare Frame Counter
  67.     Dim A As Integer                ' Dummy for SetParent
  68.     Dim newFrameHnd As Integer      ' New Frame Handle
  69.     inext = inext + 1               ' Increment Counter
  70.     Load frame1(inext)              'Create new Frame
  71.     Load check1(inext)              'Create new checkbox
  72.     newFrameHnd = frame1(inext).hWnd  'Get new Frame Handle
  73.     '**** AND THE TRICK IS.... ****
  74.     A = SetParent(check1(inext).hWnd, newFrameHnd) 'Set Checkbox parent handle to New Frame handle
  75.     frame1(inext).Caption = Str$(inext) 'Give new Frame a name
  76.     check1(inext).Caption = "This is on Form " + Str(inext)  'Checkbox name
  77.     frame1(inext).Top = frame1(inext - 1).Top + 250 'Position
  78.     frame1(inext).Left = frame1(inext - 1).Left + 250
  79.     check1(inext).Visible = -1 'Make Visible
  80.     frame1(inext).Visible = -1
  81.     frame1(inext).ZOrder 0     'Frame comes to front
  82.     combo1.AddItem Str$(inext) ' Add to list
  83. End Sub
  84. Sub Form_Load ()
  85.     combo1.AddItem " 0"
  86. End Sub
  87.